Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@otplib/core

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@otplib/core

core method for otplib

  • 12.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is @otplib/core?

@otplib/core is a library for generating and validating one-time passwords (OTPs) using various algorithms such as TOTP (Time-based One-Time Password) and HOTP (HMAC-based One-Time Password). It provides a core set of functionalities that can be extended or customized for different use cases.

What are @otplib/core's main functionalities?

Generate TOTP

This feature allows you to generate a Time-based One-Time Password (TOTP) using a shared secret. The generated token is time-sensitive and changes periodically.

const { totp } = require('@otplib/core');
const secret = 'KVKFKRCPNZQUYMLXOVYDSQKJKZDTSRLD';
const token = totp.generate(secret);
console.log(token);

Validate TOTP

This feature allows you to validate a given TOTP token against a shared secret. It returns a boolean indicating whether the token is valid.

const { totp } = require('@otplib/core');
const secret = 'KVKFKRCPNZQUYMLXOVYDSQKJKZDTSRLD';
const token = '123456';
const isValid = totp.check(token, secret);
console.log(isValid);

Generate HOTP

This feature allows you to generate an HMAC-based One-Time Password (HOTP) using a shared secret and a counter. The generated token is counter-based and changes with each increment of the counter.

const { hotp } = require('@otplib/core');
const secret = 'KVKFKRCPNZQUYMLXOVYDSQKJKZDTSRLD';
const counter = 1;
const token = hotp.generate(secret, counter);
console.log(token);

Validate HOTP

This feature allows you to validate a given HOTP token against a shared secret and a counter. It returns a boolean indicating whether the token is valid.

const { hotp } = require('@otplib/core');
const secret = 'KVKFKRCPNZQUYMLXOVYDSQKJKZDTSRLD';
const token = '123456';
const counter = 1;
const isValid = hotp.check(token, secret, counter);
console.log(isValid);

Other packages similar to @otplib/core

Keywords

FAQs

Package last updated on 24 Jan 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc